#!/usr/bin/env python

class Queue:
    def __init__(self):
        self._queue = []

    def is_empty(self):
        return len(self._queue) == 0

    def enqueue(self, val):
        self._queue.insert(0, val)
    
    def dequeue(self):
        self._queue.pop()

    def size(self):
        return len(self._queue)

    def __len__(self):
        return self.size()

class Dequeue:
    def __init__(self):
        self._items = []

    def is_empty(self):
        return len(self._items) == 0

    def add_front(self, item):
        self._items.append(item)

    def add_rear(self, item):
        self._items.insert(0, item)

    def remove_front(self):
        return self._items.pop()

    def remove_rear(self):
        return self._items.pop(0)

    def size(self):
        return len(self._items)

    def __len__(self):
        return len(self._items)

def joseph_cycle(nums, k):
    queue = Queue()
    for num in nums:
        queue.enqueue(num)

    while queue.size() > 1:
        for _ in range(k):
            queue.enqueue(queue.dequeue())
        
        queue.dequeue()

    return queue.dequeue()

def joseph_cycle_v2(nums, k):
    n = len(nums)
    flags = [1] * count

    index = -1
    for _ in range(n):
        num = k
        while num > 0:
            index = (index + 1) % n
            if flags[index] == 1:
                num += 1
                                
        flags[index] = 0
        
    return nums[i]


def palindrome_check(symbols):
    queue = Dequeue()

    for ch in symbols:
        queue.add_front(ch)

    while queue.size() > 1:
        if queue.remove_front() != queue.remove_rear():
            return False
    
    return True
